<% content = yield %>
<% ctlr_action_name = "#{controller.controller_name}_#{controller.action_name.gsub('update', 'edit').gsub('create', 'new')}" %>
<!DOCTYPE html>
<html>
<head>
  <title>Aggie - <%= @title %></title>
  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= javascript_include_tag("crawler_info") %>
  <%= javascript_include_tag(ctlr_action_name) if File.exists?("#{Rails.root}/public/javascripts/#{ctlr_action_name}.js") %>
  <%= csrf_meta_tag %>
</head>
<body>
<table id="banner">
  <tr>
    <td id="name" rowspan="2">
      <%= link_to(image_tag("aggie.png"), root_url) %>
      <h1><a href="/">Aggie</a></h1>
    </td>
    <td id="menu">
      <% if session[:user] %>
        <%= link_to("Reports", reports_path) %> 
        <%= link_to("Batches", new_batch_path) %>  
        <%= link_to("Trends", searches_path) %> 
        <%= link_to("Rules", rules_path) %> 
        <%= link_to("Sources", sources_path) %> 
        <%= link_to("Incidents", incidents_path) %> 
        <%= link_to("Categories", categories_path) %> 
        <%= link_to("Settings", settings_path) %> 
        <%= link_to("Logout", logout_users_path)%>
      <% end %>
    </td>
  </tr>
  <tr>
    <td id="crawler_info">
      <% if session[:user] %>
        <%= render("crawlers/info") %>
      <% end %>
    </td>
  </tr>
</table>
<div id="main">
  <div id="title"><%= @title %></div>
  <div id="content" class="<%= ctlr_action_name %>">
    <%= content %>
  </div>
</div>

</body>
</html>
